function love.load()
	require "client"
	print("starting UP v0.3..")
	love.graphics.setMode(640,480,false,true,0)
	ww,wh,fs,vs,aa=love.graphics.getMode()
	tickrate=0.1 -- time in ms
	print("graphics module initialized.")
	print("tickrate at "..(1/tickrate).." ticks / second.")
	count=0
	room=1
	lastroom=0
	sockets_enabled=false
	socket_id=0
	socket_waiting=false
	chat_waiting=false
	k_string=""
	_debug={tick=false,graphics=false,on=false}
	roominfo={}
	roominfo[1]={w=700,h=3000}
	objects={ }
	created={ }
	objects["player"]={x=50,y=50,speed=10,draw=function(d) love.graphics.rectangle("fill",d.x,d.y,50,50) end,step=function(d)
		if love.keyboard.isDown("d") then
			if d.x+50+d.speed<roominfo[room].w then
				objects["player"].x=d.x+d.speed
			end
		end
		if love.keyboard.isDown("a") then
			if d.x-d.speed>0 then
				objects["player"].x=d.x-d.speed
			end
		end
		if love.keyboard.isDown("s") then
			if d.y+50+d.speed<roominfo[room].h then
				objects["player"].y=d.y+d.speed
			end
		end
		if love.keyboard.isDown("w") then
			if d.y-d.speed>0 then
				objects["player"].y=d.y-d.speed
			end
		end
	end,tick=function() return end,room=1}
	print("[lAuX] framework initialized.")
		--[[ lightweight AuX engine.
			
			add an object to table OBJECTS with var room to be what room to have actions called on.
			
			callback functions include --
				- tick()
				- draw()
				- step()
				- load()
				- spawn()
				- delete()
			read-variables include -- 
				'room' - [room for display]
		]]--
		
end
function socket_init(addr)
	print("starting connection with address "..addr)
	net.connect(addr,5137)
	net.lostconnect(function() error("connection failure!") end )
	objects["otherplayer"]={x=50,y=50,speed=10,draw=function(d) love.graphics.rectangle("fill",d.x,d.y,50,50) end}
	net.action("update",function(data)
		nx,ny=data:match("(%d+)%s(%d+)")
		objects["otherplayer"].x=nx
		objects["otherplayer"].y=ny
	end)
	sockets_enabled=true
end
function love.update(dt)
	count=count+dt
	if count > tickrate then
		count=count-tickrate
		tick()
	end
	if lastroom~=room then
		for k,v in pairs(objects) do
			if v.room==room then
				if v.spawn then
					v.spawn(v)
				end
			end
		end
		lastroom=room
	end
	for k,v in pairs(objects) do
		if v.room==room then
			if v.step then
				v.step(v)
			end
		end
	end
	if sockets_enabled then
		net.process()
	end
	if love.keyboard.isDown("escape") then love.event.push("quit") end
end
function love.keypressed(key)
	if string.len(key)==1 then
	k_string=k_string..key
	end
	if key=="f3" then
		socket_waiting=true
		reskstring()
		print("starting connection, type in network address and then press ENTER")
	end
	if socket_waiting then
		if key=="return" then
			socket_init(k_string)
			socket_waiting=false
		else
		print(k_string)
		end
	end
	if chat_waiting then
		if key=="return" then
			d=string.format("%s %s %s",socket_id,'chat',k_string)
			k_string=""
			udp:send(d)
			chat_waiting=false
		else
			print(k_string)
		end
	end
	if key=="f2" then
		chat_waiting=true
		k_string=""
	end
	if key=="f11" then
		reskstring()
	end
	if k_string=="shutdown" then
		print("sending remote shutdown request..")
		d=string.format("%s %s nil",socket_id,'shutdown')
		udp:send(d)
	end
	if _debug.on then
		if key=="f1" then
			_debug.tick=not _debug.tick			
			print("tickrate at "..tickrate..", at "..(1/tickrate).." ticks per second.")
			if _debug.tick then
			print("tickrate logs turned on")
			else
			print("disabled tickrate logging.")
			end			
		end
	end
end
function getkstring()
	return k_string
end
function reskstring()
	k_string=""
end
function tick()
	-- called on tickrate ^^
	if sockets_enabled then
		net.set("x",objects["player"].x)
		net.set("Y",objects["player"].y)
	end
	c=0
	for k,v in pairs(objects) do
		if v.room==room then
			if v.tick then
				v.tick(v)
				c=c+1
			end
		end
	end
	if _debug.tick then 
		print("tick -- ran on "..c.." instances.")
	end
end
function debugmode()
	print("debug mode activated in-game.")
	_debug.on=true
end
function love.draw()
	if getkstring() == "f12debugtime" then
	if _debug.on==false then 
		debugmode()
		reskstring()
		end
	end
	cx,cy=(objects["player"].x-(ww/2)),(objects["player"].y-(wh/2))
	if cx<0 then cx=0 end
	if cx+ww>roominfo[room].w then cx=(roominfo[room].w-ww) end
	if cy<0 then cy=0 end
	if cy+wh>roominfo[room].h then cy=(roominfo[room].h-wh) end
	love.graphics.translate(-cx,-cy)
	--print(cx,cy,objects["player"].y,objects["player"].x,roominfo[room].w,roominfo[room].h)
	for k,v in pairs(objects) do
		if v.room==room then
			if v.draw then
				v.draw(v)
			end
		end
	end
	-- debug activation
end